package com.dmgis.qxfw.dataservice.bigdata.service.impl;


import com.dmgis.qxfw.dataservice.bigdata.service.IDataService;
import com.dmgis.qxfw.dataservice.businessservice.api.domain.DbConfig;
import com.dmgis.qxfw.dataservice.businessservice.api.domain.RequestDataBySelect;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.qx.doppler;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.qx.satellitenephoram;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.yj.dz_warning;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.zy.*;
import com.dmgis.qxfw.dataservice.businessservice.common.entity.*;
import com.dmgis.qxfw.dataservice.businessservice.common.util.DateTime;
import com.dmgis.qxfw.dataservice.businessservice.common.util.HttpRequestUtil;
import com.dmgis.qxfw.dataservice.businessservice.common.util.JsonUtil;
import com.dmgis.qxfw.dataservice.businessservice.common.util.StringUtil;
import com.dmgis.qxfw.dataservice.businessservice.controller.ProcessRequestController;
import com.fasterxml.jackson.core.type.TypeReference;
import com.github.kevinsawicki.http.HttpRequest;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("DataService")
public class DataServiceImpl implements IDataService {

	String result = "";
	
	ProcessRequestController pc = new ProcessRequestController();
	
	@Override
	public String getApiInfo(HttpServletRequest request) {
		// TODO 资料类别list
		List<api_type> api_Types = new ArrayList<api_type>();
		List<APIType> apiTypes = new ArrayList<APIType>();
		// 查询资料类别
		String result = "";
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		Map<String, String> map = new HashMap<String, String>();
		try {
			dataBySelect.setSort(new String[]{" id  asc"});
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "api_type");
			map.put("sqlType", "select");
			map.put("advCode", DbConfig.advCode);
			map.put("param", JsonUtil.object2Json(dataBySelect));
			result = pc.processRequest(map);
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		if (result != null && result.length() > 0) {
			try {
				api_Types = JsonUtil.jsonStr2TypeReference(result, new TypeReference<List<api_type>>() {
				});
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			// 查询资料类别
			for (api_type apiType : api_Types) {
				APIType type = new APIType();
				type.setId(apiType.getId().toString());
				type.setName(apiType.getName());
				List<APIList> apiLists = new ArrayList<APIList>();
				// 资料名称list
				List<api_interface_type> apiList = new ArrayList<api_interface_type>();
				String result1 = "";
				Map<String, String> map1 = new HashMap<String, String>();
				RequestDataBySelect dataBySelect1 = new RequestDataBySelect();
				dataBySelect1.setParam(" id = " + apiType.getId() + " ");
				try {
					map1.put("param", JsonUtil.object2Json(dataBySelect1));
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				map1.put("method", "api_interface_type");
				map1.put("sqlType", "select");
				map1.put("advCode", DbConfig.advCode);
				result1 = pc.processRequest(map1);
				// 查询资料名称
				if (result1 != null && result1.length() > 0) {
					// 数据库中对应id下的Api_interface_type信息
					try {
						apiList = JsonUtil.jsonStr2TypeReference(result1,
								new TypeReference<List<api_interface_type>>() {
								});
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					for (api_interface_type list : apiList) {
						APIList apiList2 = new APIList();
						apiList2.setApiId(list.getApi_id().toString());
						apiList2.setApiName(list.getApitype());
						apiList2.setDetail(list.getExplain());
						apiList2.setPublicUser(list.getIndustryusers());
						apiList2.setSpecialUser(list.getProfessionalusers());
						// api接口 list
						List<api_interface> apis = new ArrayList<api_interface>();
						List<API> inters = new ArrayList<API>();
						String result2 = "";
						Map<String, String> map2 = new HashMap<String, String>();
						RequestDataBySelect dataBySelect2 = new RequestDataBySelect();
						dataBySelect2.setParam(" api_id = " + list.getApi_id() + " ");
						try {
							map2.put("param", JsonUtil.object2Json(dataBySelect2));
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						map2.put("method", "api_interface");
						map2.put("sqlType", "select");
						map2.put("advCode", DbConfig.advCode);
						result2 = pc.processRequest(map2);
						// 查询api
						if (result2 != null && result2.length() > 0) {
							// 数据库中对应api_id下的接口信息
							try {
								apis = JsonUtil.jsonStr2TypeReference(result2,
										new TypeReference<List<api_interface>>() {
										});
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
							for (api_interface dbApi : apis) {
								API api = new API();
								api.setApiId(dbApi.getApi_id().toString());
								api.setExplain(dbApi.getExplain());
								api.setMethod(dbApi.getInterfacecode());
								api.setName(dbApi.getName());
								if (dbApi.getParam() != null && dbApi.getParam().length() > 0) {
									api.setParamList(dbApi.getParam().split("&"));
								}
								if (dbApi.getParamexplain() != null && dbApi.getParamexplain().length() > 0) {
									api.setParamDetail(dbApi.getParamexplain().split("&"));
								}
								if (dbApi.getParamtype() != null && dbApi.getParamtype().length() > 0) {
									api.setParamRequire(dbApi.getParamtype().split("&"));
								}
								if (dbApi.getAssignexplain() != null && dbApi.getAssignexplain().length() > 0) {
									api.setAssignments(dbApi.getAssignexplain().split("&"));
								}
								if (dbApi.getReturntype() != null && dbApi.getReturntype().length() > 0) {
									api.setReturnType(dbApi.getReturntype().split("&"));
								}
								inters.add(api);
							}
							// 把接口信息以list存放到ApiList类的IList属性下
							apiList2.setIList(inters);
						}
						apiLists.add(apiList2);
					}
				}
				type.setApiList(apiLists);
				apiTypes.add(type);
			}
		}
		String strApiTypes = "";
		try {
			strApiTypes = JsonUtil.object2Json(apiTypes);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return strApiTypes;
	}

	@Override
	public String getSmallScaleByTimeRangeId(HttpServletRequest request) {
		// TODO 基础预报- 根据时间范围、站号实况预报查询
		try {
			String timeRange = request.getParameter("timeRange");
			String stationIDs = request.getParameter("stationid");// 站点编号
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationIDs)) {
				stationIDs = stationIDs.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid in ('" + stationIDs + "')"));
			}
			dataBySelect.setSort(new String[] { "observtime desc" });
			Map<String, String> map = new HashMap<String, String>();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			map.put("param", JsonUtil.object2Json(dataBySelect));
			if (DateTime.UserMainDataTable(sdf.parse(strDate2), DbConfig.CACHEDAYS)) {
				map.put("method", "msgmediumsmallscale");
			} else {
				map.put("method", "msgmediumsmallscale");
			}
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getCityForecastByTimedateAndCounty(HttpServletRequest request) {
		// TODO 基础预报 -根据时间、时次、时效、所属县城镇预报查询
		// 必选参数
		try {
			String strDate = request.getParameter("datechar"); // 预报时间
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			DateTime dateTime = new DateTime();
			dateTime = new DateTime(sdf.parse(strDate));
			String strTime = request.getParameter("timechar"); // 预报时次
			String NTimes = request.getParameter("ntimes"); // 时效
			String county = request.getParameter("county"); // 所属县

			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			// 条件where
			StringBuilder strWhere = new StringBuilder();
			if (!StringUtil.IsNullOrEmpty(strDate)) {
				strWhere.append(String.format(" and datechar='%s'", strDate));
			}
			if (!StringUtil.IsNullOrEmpty(strTime)) {
				strWhere.append(String.format(" and timechar ='%s'", strTime));
			}
			if (!StringUtil.IsNullOrEmpty(NTimes)) {
				strWhere.append(String.format(" and ntimes ='%s'", NTimes));
			}
			if (!StringUtil.IsNullOrEmpty(county)) {
				strWhere.append(String.format(" and county ='%s'", county));
			}
			if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
				strWhere = strWhere.replace(0, 4, "");
			}
			dataBySelect.setParam(strWhere.toString());
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			if (DateTime.UserMainDataTable(dateTime.toDate(), 30)) {
				map.put("method", "forecastinfo");
			} else {
				map.put("method", "forecastinfotemp");
			}
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			e.printStackTrace();
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getFineForecastByTimedateAndCountyStaname(HttpServletRequest request) {
		// TODO 基础预报 -根据时间、时次、时效、所属县精细化预报查询
		try {
			String strDate = request.getParameter("datechar"); // 预报时间
			String strTime = request.getParameter("timechar"); // 预报时次
			String NTimes = request.getParameter("ntimes"); // 时效
			String county = request.getParameter("county"); // 所属县
			String staName = request.getParameter("stationname");// 站点名称

			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			// 条件where
			StringBuilder strWhere = new StringBuilder();
			if (!StringUtil.IsNullOrEmpty(strDate)) {
				strWhere.append(String.format(" and datechar='%s'", strDate));
			}
			if (!StringUtil.IsNullOrEmpty(strTime)) {
				strWhere.append(String.format(" and timechar ='%s'", strTime));
			}
			if (!StringUtil.IsNullOrEmpty(NTimes)) {
				strWhere.append(String.format(" and ntimes ='%s'", NTimes));
			}
			if (!StringUtil.IsNullOrEmpty(county)) {
				strWhere.append(String.format(" and 1=1"));
			}
			if (!StringUtil.IsNullOrEmpty(staName)) {
				strWhere.append(String.format(" and 2=2"));
			}
			if (!StringUtil.IsNullOrEmpty(strWhere.toString())) {
				strWhere = strWhere.replace(0, 4, "");
			}
			dataBySelect.setParam(strWhere.toString());
			dataBySelect.setSort(new String[] { "stationid desc" });
			if (!StringUtil.IsNullOrEmpty(county)) {
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "areaname='" + county + "'"));// 县或区，不用加县或区后缀
			}
			if (!StringUtil.IsNullOrEmpty(staName)) {
				dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "stationname= '" + staName + "'"));// 某某乡某某村
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "township_forecast");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getRadByTimeRangeAndTypeElevationId(HttpServletRequest request) {
		// TODO 基础预报- 根据时间范围 类型 仰角 编号查询雷达列表信息
		String timeRange = request.getParameter("timeRange");
		if (timeRange.startsWith("[")) {
			timeRange = timeRange.substring(1, timeRange.length());
		}
		if (timeRange.endsWith("]")) {
			timeRange = timeRange.substring(0, timeRange.length() - 1);
		}
		String strDate1 = timeRange.split(",")[0];// 开始时间
		String strDate2 = timeRange.split(",")[1];// 结束时间
		String strtype = request.getParameter("type");// 类型
		// 得到仰角
		String strElevation = request.getParameter("elevation");
		// 得到雷达站编号
		String strStationId = request.getParameter("stationid");
		String result = "[{\"returnState\":\"0\"}]";
		List<doppler> list = new ArrayList<doppler>();
		List<doppler> resultlist = new ArrayList<doppler>();
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		dataBySelect
				.setParam("(cast(datechar as timestamp)+ CAST(SUBSTRING(TimeChar,1,2)||'hour' as INTERVAL)) between '"
						+ strDate1 + "' and '" + strDate2 + "' and 1=1 and 2=2 and 3=3");
		if (!StringUtil.IsNullOrEmpty(strtype)) {
			dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "ldtype ='" + strtype + "'"));
		}

		if (!StringUtil.IsNullOrEmpty(strStationId)) {
			dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "stationid ='" + strStationId + "'"));
		}

		if (!StringUtil.IsNullOrEmpty(strElevation)) {
			dataBySelect.setParam(dataBySelect.getParam().replace("3=3", "elevation ='" + strElevation + "'"));
		}
		Map<String, String> map = new HashMap<String, String>();
		try {
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "doppler");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			list = JsonUtil.jsonStr2TypeReference(result, new TypeReference<List<doppler>>() {
			});
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String urls = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
		String weburl = urls + "/download.jsp?";
		if (list != null && list.size() > 0) {
			for (doppler dopp : list) {//
				doppler doppler = new doppler();
				String param = "collectionName=ld_file&stationid=" + dopp.getStationid().trim() + "&datechar="
						+ new DateTime(dopp.getDatechar()).toDateTimeString("yyyy-MM-dd") + "&timechar="
						+ dopp.getTimechar().trim() + "&ldtype=" + dopp.getLdtype().trim() + "&elevation="
						+ strElevation;
				String lbParam = param.replace("ld_file", "ld_png_file");
				String jwParam = param.replace("ld_file", "ld_bmp_file");
				doppler.setPath(weburl + param);
				doppler.setLbimgpath(weburl + lbParam);
				doppler.setJwimgpath(weburl + jwParam);
				doppler.setDatechar(dopp.getDatechar());
				doppler.setTimechar(dopp.getTimechar());
				doppler.setStationid(dopp.getStationid());
				doppler.setLdtype(dopp.getLdtype());
				doppler.setElevation(dopp.getElevation());
				// doppler.setPath(dopp.getPath());
				// doppler.setJwimgpath(dopp.getJwimgpath());
				doppler.setRadtitle(dopp.getRadtitle());
				doppler.setFwest(dopp.getFwest());
				doppler.setFeast(dopp.getFeast());
				doppler.setFsouth(dopp.getFsouth());
				doppler.setFnorth(dopp.getFnorth());
				resultlist.add(doppler);
			}
			try {
				result = JsonUtil.object2Json(resultlist);
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getCloudImgByTimerangeAndType(HttpServletRequest request) {
		// TODO 基础预报 -根据时间范围 类型查询云图列表信息
		String timeRange = request.getParameter("timeRange");
		if (timeRange.startsWith("[")) {
			timeRange = timeRange.substring(1, timeRange.length());
		}
		if (timeRange.endsWith("]")) {
			timeRange = timeRange.substring(0, timeRange.length() - 1);
		}
		String strDate1 = timeRange.split(",")[0];// 开始时间
		String strDate2 = timeRange.split(",")[1];// 结束时间
		String strtype = request.getParameter("type");// 类型
		List<satellitenephoram> list = new ArrayList<satellitenephoram>();
		List<satellitenephoram> resultlist = new ArrayList<satellitenephoram>();
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		List<String> columns = new ArrayList<String>();
		columns.add("to_char(datechar, 'yyyy-MM-dd HH24:MI:SS') as datechar");
		columns.add("TimeChar");
		columns.add("ytType");
		columns.add("Path");
		columns.add("lbimgpath");
		columns.add("jwImgPath");
		columns.add("SateTitle");
		columns.add("fwest");
		columns.add("fsouth");
		columns.add("feast");
		columns.add("fnorth");
		dataBySelect.setColumns(columns.toArray(new String[columns.size()]));
		dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
		if (!StringUtil.IsNullOrEmpty(strtype)) {
			dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "yttype ='" + strtype + "'"));
		}
		dataBySelect.setSort(new String[] { "datechar desc", "timechar desc" });
		Map<String, String> map = new HashMap<String, String>();
		try {
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "satellitenephoram");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			list = JsonUtil.jsonStr2TypeReference(result, new TypeReference<List<satellitenephoram>>() {
			});
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String urls = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
		String weburl = urls + "/download.jsp?";
		if (list != null && list.size() > 0) {
			for (satellitenephoram satelliteNephoram : list) {
				satellitenephoram satellite = new satellitenephoram();
				String param = "collectionName=yt_file&datechar="
						+ new DateTime(satelliteNephoram.getDatechar()).toDateTimeString("yyyy-MM-dd").trim()
						+ "&timechar=" + satelliteNephoram.getTimechar().trim() + "&yttype="
						+ satelliteNephoram.getYttype().trim();
				String lbparam = param.replace("yt_file", "yt_png_file");
				String jwparam = param.replace("yt_file", "yt_bmp_file");
				satellite.setPath(weburl + param);
				satellite.setLbimgpath(weburl + lbparam);
				satellite.setJwimgpath(weburl + jwparam);
				satellite.setDatechar(satelliteNephoram.getDatechar());
				satellite.setTimechar(satelliteNephoram.getTimechar());
				satellite.setYttype(satelliteNephoram.getYttype());
				satellite.setSatetitle(satelliteNephoram.getSatetitle());
				satellite.setFwest(satelliteNephoram.getFwest());
				satellite.setFeast(satelliteNephoram.getFeast());
				satellite.setFsouth(satelliteNephoram.getFsouth());
				satellite.setFnorth(satelliteNephoram.getFnorth());
				resultlist.add(satellite);
			}
			try {
				result = JsonUtil.object2Json(resultlist);
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getZhishuForcastByTimedateAndCityid(HttpServletRequest request) {
		// TODO // 指数 根据日期、时次 城市编号指数信息查询
		try {
			String strDate = request.getParameter("datechar"); // 预报时间
			String strTime = request.getParameter("timechar"); // 预报时次
			String strCityid = request.getParameter("cityid"); // 城市id
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam(
					"datechar = '" + strDate + "' and timechar = '" + strTime + "' and cityid = '" + strCityid + "'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("Param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "zhishu");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getThunderByTimerangeAndCounty(HttpServletRequest request) {
		// TODO // 雷电 根据时间范围和县名雷电查询
		try {
			String timeRange = request.getParameter("timeRange");
			String strDate1 = timeRange.substring(1, timeRange.length() - 1).split(",")[0];
			String strDate2 = timeRange.substring(1, timeRange.length() - 1).split(",")[1];
			String strCounty = request.getParameter("county");
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("observetime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(strCounty)) {
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "county like '%" + strCounty + "%'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("Param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "raiden");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String  getFireForecastByTimeRange(HttpServletRequest request) {
		// TODO 林业-森林火险
		try {
			String timeRange = request.getParameter("timeRange");
			if (timeRange != null && timeRange.length() > 0) {
				if (timeRange.startsWith("[")) {
					timeRange = timeRange.substring(1, timeRange.length());
				}
				if (timeRange.endsWith("]")) {
					timeRange = timeRange.substring(0, timeRange.length() - 1);
				}
				String strDate1 = timeRange.split(",")[0];
				String strDate2 = timeRange.split(",")[1];
				RequestDataBySelect dataBySelect = new RequestDataBySelect();
				dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "'");
				Map<String, String> map = new HashMap<String, String>();
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "hxyj_warning");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				} else {
					List<hxyj_warning> list = JsonUtil.jsonStr2TypeReference(result,
							new TypeReference<List<hxyj_warning>>() {
							});
					String urls = "http://" + request.getServerName() + ":" + request.getServerPort()
							+ request.getContextPath();
					String weburl = urls + "/download.jsp?";
					if (list != null && list.size() > 0) {
						for (hxyj_warning hxyj : list) {
							String productname = new DateTime(hxyj.getDatechar()).toDateTimeString("yyyyMMdd")
									+ hxyj.getDocid() + "森林火险预报";
							String param = "collectionName=doc_file&table_name=hxyj_warning&id=" + hxyj.getDocid()
									+ "&productname=" + productname;
							hxyj.setDocpath(weburl + param);
						}
						try {
							result = JsonUtil.object2Json(list);
						} catch (Exception e) {
							result = "[{\"returnState\":\"0\"}]";
						}
					}
				}
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getFireHistoryByTimerange(HttpServletRequest request) {
		// TODO 火险历史
		try {
			String timeRange = request.getParameter("timeRange");
			if (timeRange != null && timeRange.length() > 0) {
				if (timeRange.startsWith("[")) {
					timeRange = timeRange.substring(1, timeRange.length());
				}
				if (timeRange.endsWith("]")) {
					timeRange = timeRange.substring(0, timeRange.length() - 1);
				}
				String strDate1 = timeRange.split(",")[0];
				String strDate2 = timeRange.split(",")[1];
				RequestDataBySelect dataBySelect = new RequestDataBySelect();
				dataBySelect.setParam("announcedtime between '" + strDate1 + "' and '" + strDate2 + "'");
				Map<String, String> map = new HashMap<String, String>();
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "fire_history");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getDZWarningByTimerange(HttpServletRequest request) {
		// TODO 地灾预警
		try {
			String timeRange = request.getParameter("timeRange");
			if (timeRange != null && timeRange.length() > 0) {
				if (timeRange.startsWith("[")) {
					timeRange = timeRange.substring(1, timeRange.length());
				}
				if (timeRange.endsWith("]")) {
					timeRange = timeRange.substring(0, timeRange.length() - 1);
				}
				String strDate1 = timeRange.split(",")[0];
				String strDate2 = timeRange.split(",")[1];
				RequestDataBySelect dataBySelect = new RequestDataBySelect();
				dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "'");
				String[] sort = { "datechar desc" };
				dataBySelect.setSort(sort);
				Map<String, String> map = new HashMap<String, String>();
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "dz_warning");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				} else {
					List<dz_warning> list = JsonUtil.jsonStr2TypeReference(result,
							new TypeReference<List<dz_warning>>() {
							});
					String urls = "http://" + request.getServerName() + ":" + request.getServerPort()
							+ request.getContextPath();
					String weburl = urls + "/download.jsp?";
					if (list != null && list.size() > 0) {
						for (dz_warning hxyj : list) {
							String productname = new DateTime(hxyj.getDatechar()).toDateTimeString("yyyyMMdd")
									+ hxyj.getDocid() + "地质灾害预警";
							String param = "collectionName=doc_file&table_name=dz_warning&id=" + hxyj.getDocid()
									+ "&productname=" + productname;
							hxyj.setDocpath(weburl + param);
						}
						try {
							result = JsonUtil.object2Json(list);
						} catch (Exception e) {
							result = "[{\"returnState\":\"0\"}]";
						}
					}
				}
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getDisasterpointByDmgis_id(HttpServletRequest request) {
		// TODO 灾点查询
		String dmgis_id = request.getParameter("dmgis_id");
		String result = "请输入dmgis_id编号！";
		if (dmgis_id != null && dmgis_id.length() > 0) {
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			String[] columns = { "name", "xcoordinate", "ycoordinate", "lon", "lat", "gridcode", "scalelevel",
					" geographicposition", "threatpopulation", "threatproperty", "layers", "disasterlevel" };
			dataBySelect.setColumns(columns);
			dataBySelect.setParam("dmgis_id='" + dmgis_id + "'");
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "disaster_point");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getSL_warningByTimerange(HttpServletRequest request) {
		// TODO 水利预警数据
		String timeRange = request.getParameter("timeRange");
		String result = "";
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "sl_warning");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getTrafficForecastByTimedateAndId(HttpServletRequest request) {
		// TODO 交通气象 日期 编号
		String timeRange = request.getParameter("timeRange");
		String timechar = request.getParameter("timechar");
		String ntimes = request.getParameter("ntimes");
		String stationid = request.getParameter("stationid");
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "' and 1=1 and 2=2 and 3=3");
			if (stationid != null && stationid.length() > 0) {
				stationid = stationid.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid in ('" + stationid + "')"));
			}
			if (timechar != null && timechar.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "timechar= '" + timechar + "'"));
			}
			if (ntimes != null && ntimes.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("3=3", "ntimes= '" + ntimes + "'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "traffic_fcst");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getCityFireByTimeRangeAndId(HttpServletRequest request) {
		// TODO 城市火险 时间范围 编号
		String timeRange = request.getParameter("timeRange");
		String stationid = request.getParameter("stationid");// 站点名
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("forcastdate between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationid)) {
				stationid = stationid.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid in ('" + stationid + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "cshx_zsyb");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getWaterLoggingByTimeRange(HttpServletRequest request) {
		// TODO 内涝 日期范围
		String timeRange = request.getParameter("timeRange");
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("forecasttime between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "waterlogging_fcst");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getCropgrowdateindexlib(HttpServletRequest request) {
		// TODO 作物发育期指标
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		Map<String, String> map = new HashMap<String, String>();
		try {
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "crop_growdate_indexlib");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getDiseasesAndPestsindex(HttpServletRequest request) {
		// TODO 病虫害指标
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		Map<String, String> map = new HashMap<String, String>();
		try {
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "crop_dist_index");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getWeatherDiseasesindex(HttpServletRequest request) {
		// TODO 作物气象灾害指标
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		Map<String, String> map = new HashMap<String, String>();
		try {
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "crop_weather_dist_indexlib");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getSoil_humidityByTimerangeAndId(HttpServletRequest request) {
		// TODO 农气预报--土壤墒情
		String timeRange = request.getParameter("timeRange");
		String stationid = request.getParameter("stationid");// 站点编号
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("observetime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationid)) {
				stationid = stationid.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "StationID in ('" + stationid + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "soil_humidity");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result.equals("")) {
					result = "[]";
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getAgriStation(HttpServletRequest request) {
		// TODO 农服站点信息
		RequestDataBySelect dataBySelect = new RequestDataBySelect();
		Map<String, String> map = new HashMap<String, String>();
		try {
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "station_info");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getGrowthHistoryByIdCropnameVarietyYearGrowthname(HttpServletRequest request) {
		// TODO 发育期历史数据
		try {
			String strStationId = request.getParameter("stationid");// 站号
			String strCropName = request.getParameter("cropname");// 作物名称
			String strCropVariety = request.getParameter("cropvariety");// 作物品种
			String strYear = request.getParameter("year");// 年份
			String strGrowthName = request.getParameter("growthname");// 发育期名称
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam(" 1=1 and 2=2 and 3=3 and 4=4 and 5=5 ");
			if (strStationId != null && strStationId.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid='" + strStationId + "'"));
			}
			if (strCropName != null && strCropName.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "cropname='" + strCropName + "'"));
			}
			if (strCropVariety != null && strCropVariety.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("3=3", "type='" + strCropVariety + "'"));
			}
			if (strYear != null && strYear.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("4=4", "year='" + strYear + "'"));
			}
			if (strGrowthName != null && strGrowthName.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("5=5", "growdatename='" + strGrowthName + "'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "crop_growdate_history");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getGrowthForcastByIdCropnameVarietyYearGrowthname(HttpServletRequest request) {
		// TODO 发育期预报数据
		try {
			String strStationId = request.getParameter("stationid");// 站号
			String strCropName = request.getParameter("cropname");// 作物名称
			String strCropVariety = request.getParameter("cropvariety");// 作物品种
			String strYear = request.getParameter("year");// 年份
			String strGrowthName = request.getParameter("growthname");// 发育期名称
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam(" 1=1 and 2=2 and 3=3 and 4=4 and 5=5 ");
			if (strStationId != null && strStationId.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid='" + strStationId + "'"));
			}
			if (strCropName != null && strCropName.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "cropname='" + strCropName + "'"));
			}
			if (strCropVariety != null && strCropVariety.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("3=3", "type='" + strCropVariety + "'"));
			}
			if (strYear != null && strYear.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("4=4", "year='" + strYear + "'"));
			}
			if (strGrowthName != null && strGrowthName.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("5=5", "growdatename='" + strGrowthName + "'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "crop_growdate_fcst");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getYieldHistoryByIdCropnameCropvarietyYear(HttpServletRequest request) {
		// TODO 农作物产量历史数据
		String strStationId = request.getParameter("stationid");// 站号
		String strCropName = request.getParameter("cropname");// 作物名称
		try {
			// strCropName = new String(strCropName.getBytes("ISO-8859-1"),
			// "UTF-8");
			String strCropVariety = request.getParameter("cropvariety");// 作物品种
			String strYear = request.getParameter("year");// 年份
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam(" 1=1 and 2=2 and 3=3 and 4=4 and 5=5 ");
			if (strStationId != null && strStationId.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid='" + strStationId + "'"));
			}
			if (strCropName != null && strCropName.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "cropname='" + strCropName + "'"));
			}
			if (strCropVariety != null && strCropVariety.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("3=3", "type='" + strCropVariety + "'"));
			}
			if (strYear != null && strYear.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("4=4", "year='" + strYear + "'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "cropyield_history");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getYieldForcastByIdCropnameCropvarietyYear(HttpServletRequest request) {
		// TODO 农作物产量预报数据
		String strStationId = request.getParameter("stationid");// 站号
		String strCropName = request.getParameter("cropname");// 作物名称
		try {
			String strCropVariety = request.getParameter("cropvariety");// 作物品种
			String strYear = request.getParameter("year");// 年份
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam(" 1=1 and 2=2 and 3=3 and 4=4 and 5=5 ");
			if (strStationId != null && strStationId.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid='" + strStationId + "'"));
			}
			if (strCropName != null && strCropName.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("2=2", "cropname='" + strCropName + "'"));
			}
			if (strCropVariety != null && strCropVariety.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("3=3", "type='" + strCropVariety + "'"));
			}
			if (strYear != null && strYear.length() > 0) {
				dataBySelect.setParam(dataBySelect.getParam().replace("4=4", "year='" + strYear + "'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "cropyield_fcst");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getAgri_productByTimerange(HttpServletRequest request) {
		// TODO 农业产品 通过时间范围
		String timeRange = request.getParameter("timeRange");
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("forecasttime between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "agri_product");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
				if (result != null && result.length() > 0) {
					List<agri_product> list = JsonUtil.jsonStr2TypeReference(result,
							new TypeReference<List<agri_product>>() {
							});
					String urls = "http://" + request.getServerName() + ":" + request.getServerPort()
							+ request.getContextPath();
					String weburl = urls + "/download.jsp?";
					if (list != null && list.size() > 0) {
						for (agri_product agr : list) {
							String param = "collectionName=doc_file&table_name=agri_product&id="
									+ agr.getId().toString() + "&productname=" + agr.getProductname().trim();
							agr.setProductpath(weburl + param);
						}
						try {
							result = JsonUtil.object2Json(list);
						} catch (Exception e) {
							result = "[{\"returnState\":\"0\"}]";
						}
					}
				}
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getTourForecastByTimeRangeSta(HttpServletRequest request) {
		// TODO 景点预报信息 时间范围、站号
		String timeRange = request.getParameter("timeRange");
		String stationid = request.getParameter("stationid");
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (stationid != null && stationid.length() > 0) {
				stationid = stationid.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid in ('" + stationid + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "tour_fcst");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getTourSmallScaleByTimeRangeAndId(HttpServletRequest request) {
		// TODO 景点实况信息查询 时间范围
		String timeRange = request.getParameter("timeRange");
		String stationid = request.getParameter("stationid");
		if (timeRange != null && timeRange.length() > 0) {
			if (timeRange.startsWith("[")) {
				timeRange = timeRange.substring(1, timeRange.length());
			}
			if (timeRange.endsWith("]")) {
				timeRange = timeRange.substring(0, timeRange.length() - 1);
			}
			String strDate1 = timeRange.split(",")[0];
			String strDate2 = timeRange.split(",")[1];
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (stationid != null && stationid.length() > 0) {
				stationid = stationid.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "stationid in ('" + stationid + "')"));
			}
			dataBySelect.setSort(new String[] { "observtime desc" });
			Map<String, String> map = new HashMap<String, String>();
			try {
				map.put("param", JsonUtil.object2Json(dataBySelect));
				map.put("method", "tour_smallscale");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
			} catch (Exception e) {
				result = "[{\"returnState\":\"0\"}]";
			}
		}
		return result;
	}

	@Override
	public String getZhiSHuForcastByTimeRangeCityid(HttpServletRequest request) {
		// TODO 旅游指数预报 时间范围 地区编号
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String strCityids = request.getParameter("cityid"); // 城市编号
			Map<String, String> zs = new HashMap<String, String>();
			zs.put("ZZ", "着装气象指数");
			zs.put("MB", "霉变气象指数");
			zs.put("LS", "晾晒气象指数");
			zs.put("RD", "城市热岛指数");
			zs.put("SS", "人体舒适度指数");
			zs.put("ZW", "紫外线指数");
			zs.put("YS", "雨伞指数");
			zs.put("LYOU", "旅游气象指数");
			zs.put("JT", "交通气象指数");
			zs.put("CL", "晨练气象指数");
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(strCityids)) {
				strCityids = strCityids.replace(",", "','");
				dataBySelect.setParam(dataBySelect.getParam().replace("1=1", "cityid in ('" + strCityids + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "zhishu");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			List<zhishu> list = JsonUtil.jsonStr2TypeReference(result, new TypeReference<List<zhishu>>() {
			});
			List<ZhiShuList> listResult = new ArrayList<ZhiShuList>();
			for (zhishu row : list) {

				List<ZhiShu> zsList = new ArrayList<ZhiShu>();
				for (String key : zs.keySet()) {
					ZhiShu model = new ZhiShu();
					model.setName(zs.get(key));
					if (key.equals("ZZ")) {
						model.setLevel(row.getZzgrade());
						model.setText(row.getZztext());
					}
					if (key.equals("MB")) {
						model.setLevel(row.getMbgrade());
						model.setText(row.getMbtext());
					}
					if (key.equals("LS")) {
						model.setLevel(row.getLsgrade());
						model.setText(row.getLstext());
					}
					if (key.equals("RD")) {
						model.setLevel(row.getRdgrade());
						model.setText(row.getRdtext());
					}
					if (key.equals("SS")) {
						model.setLevel(row.getSsgrade());
						model.setText(row.getSstext());
					}
					if (key.equals("ZW")) {
						model.setLevel(row.getZwgrade());
						model.setText(row.getZwtext());
					}
					if (key.equals("YS")) {
						model.setLevel(row.getYsgrade());
						model.setText(row.getYstext());
					}
					if (key.equals("LYOU")) {
						model.setLevel(row.getLyougrade());
						model.setText(row.getLyoutext());
					}
					if (key.equals("JT")) {
						model.setLevel(row.getJtgrade());
						model.setText(row.getJttext());
					}
					if (key.equals("CL")) {
						model.setLevel(row.getClgrade());
						model.setText(row.getCltext());
					}
					zsList.add(model);
				}
				ZhiShuList zsResult = new ZhiShuList();
				zsResult.setCityName(row.getCityname().trim());
				zsResult.setZhiShuInfo(JsonUtil.object2Json(zsList));
				zsResult.setDate(new DateTime(row.getDatechar()).toDateTimeString("yyyy-MM-dd"));
				zsResult.setSc(row.getTimechar().trim());
				String x = row.getLongitude().toString().trim();
				String y = row.getLatitude().toString().trim();
				zsResult.setLongitude(Double.parseDouble(x));
				zsResult.setLatitude(Double.parseDouble(y));
				listResult.add(zsResult);
			}
			result = (JsonUtil.object2Json(listResult)).replace("\\", "").replace("\"[", "[").replace("]\"", "]");
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getTourProductByTimerangeType(HttpServletRequest request) {
		// TODO 旅游产品 时间范围 类型 //未入库
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String producttype = request.getParameter("producttype");// 产品类型
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("forecasttime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(producttype)) {
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "producttype = '" + producttype + "'"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "base_product");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result != null && result.length() > 0) {
				List<tourist_product> list = JsonUtil.jsonStr2TypeReference(result,
						new TypeReference<List<tourist_product>>() {
						});
				String urls = "http://" + request.getServerName() + ":" + request.getServerPort()
						+ request.getContextPath();
				String weburl = urls + "/download.jsp?";
				if (list != null && list.size() > 0) {
					for (tourist_product tour : list) {
						String param = "";
						if (tour.getProductname().endsWith(".doc")) {
							param = "collectionName=doc_file&table_name=base_product&id=" + tour.getId().toString()
									+ "&productname=" + tour.getProductname().trim();
						}
						if (tour.getProductname().endsWith(".txt")) {
							param = "collectionName=txt_file&table_name=base_product&id=" + tour.getId().toString()
									+ "&productname=" + tour.getProductname().trim();
						}
						tour.setProductpath(weburl + param);
					}
					try {
						result = JsonUtil.object2Json(list);
					} catch (Exception e) {
						result = "[{\"returnState\":\"0\"}]";
					}
				}
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getSum_atmospheric_day_dataByTimerangeId(HttpServletRequest request) {
		// TODO 大气日数据汇总表 时间范围 站点编号
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String stationIDs = request.getParameter("stationid");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationIDs)) {
				stationIDs = stationIDs.replace(",", "','");
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "stationid in ('" + stationIDs + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "sum_atmospheric_day_data");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getAirpollutionByTimerangeId(HttpServletRequest request) {
		// TODO 空气污染 时间范围站点编号
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String stationIDs = request.getParameter("stationid");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationIDs)) {
				stationIDs = stationIDs.replace(",", "','");
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "stationid in ('" + stationIDs + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "airpollution");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getAirpol_con_fcstByTimerange(HttpServletRequest request) {
		// TODO /空气污染指数预报 时间范围
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "airpol_con_fcst");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getAirpol_reg_fcstByTimerange(HttpServletRequest request) {
		// TODO 空气污染回归预报 时间范围
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "airpol_reg_fcst");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getAirpol_fcstByTimerangeAndId(HttpServletRequest request) {
		// TODO 空气污染预报 时间范围 站点编号
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String stationIDs = request.getParameter("stationid");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationIDs)) {
				stationIDs = stationIDs.replace(",", "','");
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "stationid in ('" + stationIDs + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "airpol_fcst");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getAir_haze_warnByTimerange(HttpServletRequest request) {
		// TODO 空气霾预警 时间范围
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "air_haze_warn");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getHazevisibility_forecastByTimerangeNtimes(HttpServletRequest request) {
		// TODO 霾能见度预报 时间范围和时效
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String ntimes = request.getParameter("ntimes");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(ntimes)) {
				ntimes = ntimes.replace(",", "','");
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "ntimes in ('" + ntimes + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "hazevisibility_forecast");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getHeavy_forecastByTimerange(HttpServletRequest request) {
		// TODO 重度预报 时间范围
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("time between '" + strDate1 + "' and '" + strDate2 + "'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "heavy_forecast");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getHigh_elementsByTimerangeId(HttpServletRequest request) {
		// TODO 高空要素 时间范围 站点编号
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String stationIDs = request.getParameter("stationid");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("observtime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(stationIDs)) {
				stationIDs = stationIDs.replace(",", "','");
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "stationid in ('" + stationIDs + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "high_elements");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getEnvirostationById(HttpServletRequest request) {
		// TODO 环保站 站点编号
		try {
			String stationIDs = request.getParameter("stationid");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("1=1");
			if (!StringUtil.IsNullOrEmpty(stationIDs)) {
				stationIDs = stationIDs.replace(",", "','");
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "stationid in ('" + stationIDs + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "envirostation");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getHidedanger_pointById(HttpServletRequest request) {
		// TODO 隐患点 灾点编号
		try {
			String disasterpointid = request.getParameter("disasterpointid");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("1=1");
			if (!StringUtil.IsNullOrEmpty(disasterpointid)) {
				disasterpointid = disasterpointid.replace(",", "','");
				dataSelect.setParam(
						dataSelect.getParam().replace("1=1", "disasterpointid in ('" + disasterpointid + "')"));
			}
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "hidedanger_point");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getWarningByTimerange(HttpServletRequest request) {
		// TODO 预警 时间范围
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			if (strDate1.equals("") || strDate2.equals("")) {
				result = "请输入时间!";
			} else {
				dataSelect.setParam("announcedtime between '" + strDate1 + "' and '" + strDate2 + "'");
				Map<String, String> map = new HashMap<String, String>();
				map.put("param", JsonUtil.object2Json(dataSelect));
				map.put("method", "warning");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getHourPowerLoadByTimerange(HttpServletRequest request) {
		// TODO 根据时间范围逐小时负荷预报
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			if (strDate1.equals("") || strDate2.equals("")) {
				result = "请输入时间!";
			} else {
				dataSelect.setParam("datechar between '" + strDate1 + "' and '" + strDate2 + "'");
				dataSelect.setSort(new String[] { "datechar desc" });
				Map<String, String> map = new HashMap<String, String>();
				map.put("param", JsonUtil.object2Json(dataSelect));
				map.put("method", "powerload_hour_fcst");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getDayPowerLoadByTimedate(HttpServletRequest request) {
		// TODO 根据日期,时次,时效日最大负荷预报
		try {
			String datechar = request.getParameter("datechar");
			String timechar = request.getParameter("timechar");
			String ntimes = request.getParameter("ntimes");
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			if (datechar.equals("") || timechar.equals("") || ntimes.equals("")) {
				result = "请输入日期、时次或时效!";
			} else {
				dataSelect.setParam("datechar = '" + datechar + "' and timechar = '" + timechar + "' and ntimes = '"
						+ ntimes + "'");
				Map<String, String> map = new HashMap<String, String>();
				map.put("param", JsonUtil.object2Json(dataSelect));
				map.put("method", "max_powerload_fcst");
				map.put("sqlType", "select");
				result = pc.processRequest(map);
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getPowerProductListBytimeRangeAndProducttype(HttpServletRequest request) {
		// TODO 根据时间范围，产品类型电力获取产品信息
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String producttype = request.getParameter("producttype");// 产品类型
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setParam("forecasttime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(producttype)) {
				dataSelect.setParam(dataSelect.getParam().replace("1=1", "producttype = '" + producttype + "'"));
			}
			dataSelect.setSort(new String[] { "forecasttime desc" });
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "power_product");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result != null && result.length() > 0) {
				List<power_product> list = JsonUtil.jsonStr2TypeReference(result,
						new TypeReference<List<power_product>>() {
						});
				String urls = "http://" + request.getServerName() + ":" + request.getServerPort()
						+ request.getContextPath();
				String weburl = urls + "/download.jsp?";
				if (list != null && list.size() > 0) {
					for (power_product pwp : list) {
						String param = "";
						if (pwp.getProductname().endsWith(".doc")) {
							param = "collectionName=doc_file&table_name=power_product&id=" + pwp.getId().toString()
									+ "&productname=" + pwp.getProductname().trim();
						}
						if (pwp.getProductname().endsWith(".txt")) {
							param = "collectionName=txt_file&table_name=power_product&id=" + pwp.getId().toString()
									+ "&productname=" + pwp.getProductname().trim();
						}
						pwp.setProductname(weburl + param);
					}
					try {
						result = JsonUtil.object2Json(list);
					} catch (Exception e) {
						result = "[{\"returnState\":\"0\"}]";
					}
				}
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}

	@Override
	public String getZhongbaoProductListBytimeRangeAndProducttype(HttpServletRequest request) {
		// TODO 根据时间范围，产品类型获取中保产品信息
		try {
			String timeRange = request.getParameter("timeRange");
			timeRange = timeRange.substring(1, timeRange.length() - 1);
			String strDate1 = timeRange.split(",")[0]; // 开始时间
			String strDate2 = timeRange.split(",")[1]; // 开始时间
			String producttype = request.getParameter("producttype");// 产品类型
			String productpath = "";
			RequestDataBySelect dataSelect = new RequestDataBySelect();
			dataSelect.setColumns(new String[] { "productpath" });
			dataSelect.setParam("jobname='" + producttype + "' and jobtype='人保气象'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataSelect));
			map.put("method", "job_make");
			map.put("sqlType", "select");
			String result0 = pc.processRequest(map);
			List<job_make> list2 = JsonUtil.jsonStr2TypeReference(result0, new TypeReference<List<job_make>>() {
			});
			for (job_make item : list2) {
				productpath = item.getProductpath();
			}

			RequestDataBySelect dataSelect1 = new RequestDataBySelect();
			dataSelect1.setParam("forecasttime between '" + strDate1 + "' and '" + strDate2 + "' and 1=1");
			if (!StringUtil.IsNullOrEmpty(producttype)) {
				dataSelect1.setParam(dataSelect1.getParam().replace("1=1", "producttype = '" + producttype + "'"));
			}
			dataSelect1.setSort(new String[] { "forecasttime desc" });
			Map<String, String> map1 = new HashMap<String, String>();
			map1.put("param", JsonUtil.object2Json(dataSelect1));
			map1.put("method", "zhongbao_product");
			map1.put("sqlType", "select");
			String result1 = pc.processRequest(map);
			List<zhongbao_product> list = JsonUtil.jsonStr2TypeReference(result1,
					new TypeReference<List<zhongbao_product>>() {
					});
			List<ProductInfo> listResult = new ArrayList<ProductInfo>();
			for (zhongbao_product item : list) {
				try {
					ProductInfo pif = new ProductInfo();
					pif.setProductName(item.getProductname().toString().trim());
					pif.setProductType(item.getProducttype().toString().trim());
					pif.setProductPath(productpath.trim() + pif.getProductName());/////// 路径////////
					pif.setForcastDate(new DateTime(item.getForecasttime()).toDateTimeString("yyyy-MM-dd HH:mm:ss"));
					pif.setMakeDate(new DateTime(item.getForecasttime()).toDateTimeString("yyyy-MM-dd HH:mm:ss"));
					pif.setMaker(item.getMaker().toString().trim());
					listResult.add(pif);
				} catch (Exception e) {

				}
			}
			result = JsonUtil.object2Json(listResult).replace("\\\\", "\\");

		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"]";
		}
		return result;
	}

	@Override
	public String getWeekWeatherBynTimesAndCountyStaname(HttpServletRequest request) {
		// TODO Auto-generated method stub
		try {
			String strDate = request.getParameter("datechar"); // 预报时间
			String strtime = request.getParameter("timechar"); // 预报时间
			String strTime = request.getParameter("ntimes"); // 预报时次
			String strCityid = request.getParameter("stationid"); // 城市id
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			dataBySelect.setParam("datechar = '" + strDate + "' and timechar = '" + strtime + "' and ntimes >='"
					+ 12 + "' and ntimes  <='" + 168 + "'  and stationid = '" + strCityid + "'");
			Map<String, String> map = new HashMap<String, String>();
			map.put("param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "township_forecasttemp");
			map.put("sqlType", "select");
			result = pc.processRequest(map);
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;

	}

	@Override
	public String getceshi(HttpServletRequest request) {
		// TODO Auto-generated method stub
		try {
			RequestDataBySelect dataBySelect = new RequestDataBySelect();
			Map<String, String> map = new HashMap<String, String>();
			map.put("Param", JsonUtil.object2Json(dataBySelect));
			map.put("method", "sta_info_surf_chn_n");
			map.put("sqlType", "select");
			if (result.equals("")) {
				result = "[]";
			}
		} catch (Exception e) {
			result = "[{\"returnState\":\"0\"}]";
		}
		return result;
	}
}
